import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int q = in.nextInt();
            long[][] arr = new long[q][3];
            long[] ret = new long[q];
            for(int i = 0;i < q;i++){
                int count = 0;
                for (int j = 0; j < 3; j++) {
                    arr[i][j] = in.nextInt();
                }
                if(arr[i][1] == 0){
                    ret[i] = count;
                    continue;
                }
                while(arr[i][0] != 0){
                    if(arr[i][1] == 0 || arr[i][2] == 0){
                        break;
                    }else{
                        count += 2;
                        arr[i][0] --;
                        arr[i][1] --;
                        arr[i][2] --;
                    }
                }
                if(arr[i][1] > 2){
                    count += arr[i][1] - 1;
                }
                ret[i] = count;
            }
            for (int i = 0; i < ret.length; i++) {
                System.out.println(ret[i]);
            }
        }
    }
}